package com.cw.subject.infra.basic.service.impl;

import com.cw.subject.infra.basic.entity.SubjectBriefPO;
import com.cw.subject.infra.basic.mapper.SubjectBriefPODao;
import com.cw.subject.infra.basic.service.SubjectBriefPOService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 简答题(SubjectBriefPO)表服务实现类
 *
 * @author makejava
 * @since 2024-04-11 15:15:03
 */
@Service("subjectBriefService")
public class SubjectBriefPOServiceImpl implements SubjectBriefPOService {
    @Resource
    private SubjectBriefPODao subjectBriefPODao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SubjectBriefPO queryById(Integer id) {
        return this.subjectBriefPODao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param subjectBriefPO 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectBriefPO insert(SubjectBriefPO subjectBriefPO) {
        this.subjectBriefPODao.insert(subjectBriefPO);
        return subjectBriefPO;
    }

    /**
     * 修改数据
     *
     * @param subjectBriefPO 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectBriefPO update(SubjectBriefPO subjectBriefPO) {
        this.subjectBriefPODao.update(subjectBriefPO);
        return this.queryById(subjectBriefPO.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.subjectBriefPODao.deleteById(id) > 0;
    }

    @Override
    public SubjectBriefPO queryByCondition(SubjectBriefPO subjectBriefPO) {
        return this.subjectBriefPODao.queryAllByLimit(subjectBriefPO);
    }
}
